package com.spyx.product.service.impl;


import com.atyx.spyx.model.product.Category;
import com.atyx.spyx.vo.product.CategoryQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spyx.product.mapper.CategoryMapper;
import com.spyx.product.service.CategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 商品三级分类 服务实现类
 * </p>
 *
 * @author yhp
 * @since 2024-05-15
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Override
    public IPage<Category> getPageList(Page p1, CategoryQueryVo queryVo) {

        String name = queryVo.getName();
        LambdaQueryWrapper<Category> wrapper = new LambdaQueryWrapper<Category>();
        if(!StringUtils.isEmpty(name)){
            wrapper.like(Category::getName,name);
        }

        IPage pageModel = baseMapper.selectPage(p1, wrapper);

        return pageModel;
    }

    @Override
    public List<Category> getcategoryListbyids(List<Long> ids) {

        return baseMapper.selectBatchIds(ids);
    }

    @Override
    public List<Category> getAll() {
        return baseMapper.selectList(null);
    }
}
